package top.laoshuzi.android.mvp;

import java.lang.reflect.Constructor;

import top.laoshuzi.android.mvp.view.MVPBinder;

public class MVP {

    public static MVPBinder bind(Object object) {
        try {
            Class<? extends MVPBinder> bindClazz = (Class<? extends MVPBinder>) Class.forName(object.getClass().getName() + "_MVPPresenterBinding");
            // 构造函数
            Constructor<? extends MVPBinder> bindConstructor = bindClazz.getDeclaredConstructor(object.getClass());

            MVPBinder unbinder = bindConstructor.newInstance(object);
            return unbinder;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return MVPBinder.EMPTY;
    }

}
